package cn.zzp.ggkt.vod.constant;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author Administrator
 * @description: 腾讯云常量类,读取yml文件中的配置数据
 * @date 2022/8/25 1:47
 */
@Component
public class TencentCosConstant implements InitializingBean { // InitializingBean spring提供的接口，用于初始化bean的时候自定义执行方法

    @Value("${tencent.cos.file.region}")
    private String region;

    @Value("${tencent.cos.file.secretid}")
    private String secretId;

    @Value("${tencent.cos.file.secretkey}")
    private String secretKey;

    @Value("${tencent.cos.file.bucketname}")
    private String bucketName;

    public static String REGION ;
    public static String ACCESS_KEY_ID ;
    public static String ACCESS_KEY_SECRET ;
    public static String BUCKET_NAME ;

    /**
     * 读取配置文件之后运行的方法
     * 给常量赋值
     * @throws Exception
     */
    @Override
    public void afterPropertiesSet() throws Exception {
        REGION = region;
        ACCESS_KEY_ID = secretId;
        ACCESS_KEY_SECRET = secretKey;
        BUCKET_NAME = bucketName;
    }
}
